//
//  AppDelegate.m
//  MaxMovie
//
//  Created by Maxdong on 14-12-24.
//  Copyright (c) 2014年 maxdong. All rights reserved.
//

#import "AppDelegate.h"
#import "ShowViewController.h"
#import "CinemaViewController.h"
#import "WillViewController.h"
#import "SetViewController.h"
#import "VideoViewController.h"
#import "NewsData.h"
#import "ImageViewController.h"
#import "TopViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    
    
//    
//    //* -------ShareSDK
//    
//    
//    [ShareSDK registerApp:@"25c976402f08"];
//    [ShareSDK connectSinaWeiboWithAppKey:@"1161422234"
//                               appSecret:@"f8857348e97e897a04040104b91e3db9"
//                             redirectUri:@"http://www.lanou3g.com"];
//    
//    [ShareSDK connectTencentWeiboWithAppKey:@"801525832"
//                                  appSecret:@"76ace6757744edb607df33cc48d7543c"
//                                redirectUri:@"http://www.lanou3g.com"];
//    
//    
//    
////
////    [Parse setApplicationId:@"pwmk2G3JmaQDfKLe5n3zSD2FNdMlq3icypZ2hSpT"
////                  clientKey:@"1oES9C8duR6ReSBg8UTZ61fIk9IeR3exGBkQorRM"];
////    
////    //-------------
//    
//    
//    
    
    
    
    _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    _window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    UITabBarController *tabBarVC = [[UITabBarController alloc]init];
    
    
    //首页 正在热映
    ShowViewController *showVC = [[ShowViewController alloc]init];
    showVC.title = @"✨MaxMovie✨";
    UIImage *image1 = [UIImage imageNamed:@"1.png"];
    showVC.tabBarItem = [[[UITabBarItem alloc]initWithTitle:@"首页" image:image1 tag:0] autorelease];
    UINavigationController *showNavi = [[[UINavigationController alloc]initWithRootViewController:showVC]autorelease];
    tabBarVC.tabBar.barTintColor = [UIColor whiteColor];
    tabBarVC.tabBar.tintColor = [UIColor magentaColor];
    
    [showVC release];
    
    //即将上映
    WillViewController *willVC = [[WillViewController alloc]init];
    willVC.title = @"✨Comming Soon✨";
    willVC.tabBarItem = [[[UITabBarItem alloc]initWithTitle:@"即将上映" image:[UIImage imageNamed:@"2.png"] tag:0] autorelease];
    UINavigationController *willNavi = [[[UINavigationController alloc]initWithRootViewController:willVC] autorelease];
    [willVC release];
    
    
    
    //预告
    VideoViewController *videoVC = [[VideoViewController alloc]init];
    videoVC.title = @"✨Trailer✨";
    UIImage *image3 = [UIImage imageNamed:@"5.png"];
    videoVC.tabBarItem = [[[UITabBarItem alloc]initWithTitle:@"预告" image:image3 tag:1] autorelease];
    UINavigationController *VideoNavi = [[[UINavigationController alloc]initWithRootViewController:videoVC]autorelease];
    [videoVC release];
    
    
    //影院
    CinemaViewController *cinemaVC = [[CinemaViewController alloc]init];
    cinemaVC.title = @"✨MaxMovie News✨";
    UIImage *image2 = [UIImage imageNamed:@"3.png"];
    cinemaVC.tabBarItem = [[[UITabBarItem alloc]initWithTitle:@"新闻" image:image2 tag:1] autorelease];
    UINavigationController *cineNavi = [[[UINavigationController alloc]initWithRootViewController:cinemaVC]autorelease];
    [cinemaVC release];
    
    
    //我
    SetViewController *SetVC = [[SetViewController alloc]init];
    SetVC.title = @"✨My Center✨";
    SetVC.tabBarItem = [[[UITabBarItem alloc]initWithTitle:@"更多" image:[UIImage imageNamed:@"4.png"] tag:0]autorelease];
    UINavigationController *setNavi = [[[UINavigationController alloc]initWithRootViewController:SetVC]autorelease];
    [SetVC release];
    
     //top页面
//    TopViewController * topVC =[[TopViewController alloc] init];
//    topVC.title =@"Max精选";
//    topVC.tabBarItem = [[[UITabBarItem alloc]initWithTitle:@"Max精选" image:[UIImage imageNamed:@"4.png"] tag:0]autorelease];
//    UINavigationController *topNavi = [[[UINavigationController alloc]initWithRootViewController:topVC]autorelease];
//    [topVC release];

    
 
    
    
    //首页 页头颜色
     [showNavi.navigationBar setBarTintColor:[UIColor colorWithRed:128.0 / 255.0 green:0.0 / 255.0 blue:128.0 / 255.0 alpha:2.0]];
    //title颜色
    [showNavi.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:255.0 / 255.0 green:215.0 / 255.0 blue:0.0 / 255.0 alpha:1.0], NSForegroundColorAttributeName, nil]];
    
    
    //即将上映 页头颜色
    [willNavi.navigationBar setBarTintColor:[UIColor colorWithRed:128.0 / 255.0 green:0.0 / 255.0 blue:128.0 / 255.0 alpha:1.0]];
    //title颜色
    [willNavi.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:255.0 / 255.0 green:215.0 / 255.0 blue:0.0 / 255.0 alpha:1.0], NSForegroundColorAttributeName, nil]];
    
    
    //预告 页头颜色
    [VideoNavi.navigationBar setBarTintColor:[UIColor colorWithRed:128.0 / 255.0 green:0.0 / 255.0 blue:128.0 / 255.0 alpha:1.0]];
    //title颜色
    [VideoNavi.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:255.0 / 255.0 green:215.0 / 255.0 blue:0.0 / 255.0 alpha:1.0], NSForegroundColorAttributeName, nil]];
    
    
    //影院 页头颜色
    [cineNavi.navigationBar setBarTintColor:[UIColor colorWithRed:128.0 / 255.0 green:0.0 / 255.0 blue:128.0 / 255.0 alpha:1.0]];
    //title颜色
    [cineNavi.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:255.0 / 255.0 green:215.0 / 255.0 blue:0.0 / 255.0 alpha:1.0], NSForegroundColorAttributeName, nil]];
    
    
    //我 页头颜色
    [setNavi.navigationBar setBarTintColor:[UIColor colorWithRed:128.0 / 255.0 green:0.0 / 255.0 blue:128.0 / 255.0 alpha:1.0]];
    //title颜色
    [setNavi.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:255.0 / 255.0 green:215.0 / 255.0 blue:0.0 / 255.0 alpha:1.0], NSForegroundColorAttributeName, nil]];
    

    
    
    NSMutableArray *vcs = [NSMutableArray arrayWithObjects:showNavi, willNavi, VideoNavi, cineNavi,setNavi, nil];
    tabBarVC.viewControllers = vcs;
    
    self.window.rootViewController = tabBarVC;
    [tabBarVC release];
    
    
    
    NewsData *newsData = [NewsData shareInstance];
    [newsData openDB];
    [newsData creatNewsTable];
    
    
    
    
    return YES;
    
}




//////----------ShareSDK
//
//
//- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
//{
//    return [ShareSDK handleOpenURL:url wxDelegate:nil];
//}
//
//- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
//{
//    return [ShareSDK handleOpenURL:url
//                 sourceApplication:sourceApplication
//                        annotation:annotation
//                        wxDelegate:nil];
//}
//////------------




-(void)dealloc
{
    [_window release];
    [super dealloc];
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
